
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);

const routes = [

  {
    path: "/login",
    name: "login",
    component: () => import("../view/login.vue"),
    meta: {
      title: "登录",
      isJudge: false
    }
  },
  {
    path: "/home",
    name: "home", 
    component: () => import("../view/home.vue"),
    meta: {
      title: "home",
      isJudge: true
    },
    children: [
      {
        path: "indexx",
        name: "indexx",
        component: () => import("../view/indexx.vue"),
        meta: {
          title: "indexx",
          isJudge: true
        }
      },
      {
        path: "usercenter",
        name: "user",
        component: () => import("../view/user/usercenter.vue"),
        meta: {
          title: "usercenter",
          isJudge: true
        }
      },
      {
        path: "user",
        name: "user",
        component: () => import("../view/sys/user.vue"),
        meta: {
          title: "user",
          isJudge: true
        }
      },
      {
        path: "role",
        name: "role",
        component: () => import("../view/sys/role.vue"),
        meta: {
          title: "role",
          isJudge: true
        }
      },
      {
        path: "meun",
        name: "meun",
        component: () => import("../view/sys/meun.vue"),
        meta: {
          title: "meun",
          isJudge: true
        }
      },
    ]
  }
]

const router = new VueRouter({
  routes

})


// router.beforeEach((to, from, next) => {
//   console.log(to)

//   if (to.meta.isJudge && !sessionStorage.getItem("mytoken")) {

//     next({ path: "/login" })
//   } else {
//     next()
//   }
// })


export default router